package Day013_线程安全.ZuoYe.Test2;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author zhangyan
 * @date 2020/5/4 18:14
 */
public class MyRunnable implements Runnable {
    String name;

    public MyRunnable(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        System.out.println("我需要一个老师");
        //两秒定时器
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println(name + "来辅导...");
                System.out.println("教我java,教完后，老师回到了办公室");
            }
        }, 2000);
    }
}
